<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>location对象</title>
</head>

<body>
  <div>5</div>
  <script>
    // 场景:用来跳转页面
    console.log(location);
    // setTimeout(function () {
    // location.href = 'https://www.baidu.com/?tn=85070231_30_hao_pg'
    // }, 2000)

    const div = document.querySelector('div')
    let num = 5
    let timer = setInterval(function () {
      num--
      div.innerHTML = `${num}`
      if (num === 0) {
        clearInterval(timer)
        location.href = 'https://www.baidu.com/?tn=85070231_30_hao_pg'
      }
    }, 1000)
  </script>
</body>

</html>